<%@page import="models.AnnounceManagement"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -->

<jsp:include page="../includes/header.jsp"></jsp:include>
<jsp:include page="../includes/adminmenu.jsp"></jsp:include>

<%
	ArrayList<String> contents = (ArrayList) session
			.getAttribute("contents");
	AnnounceManagement am = new AnnounceManagement();
%>
<div class="container">
	<div class="panel panel-info setmainwidth">
		<div class="panel-heading">
			<div class="panel-title">Quản lý thông báo</div>
		</div>
		<div class="panel-body">
			<table class="table table-condensed">
				<tr class="danger">
					<td>Ngày đăng</td>
					<td>Nội dung</td>
					<td>Tùy chọn</td>
				</tr>
				<%
					for (int i = 0; i < contents.size(); i++) {
				%>
				<tr>
					<td><%=am.getDate(contents.get(i))%></td>
					<%
						String fixContent = "";
							if (contents.get(i).length() >= 100)
								fixContent = contents.get(i).substring(0, 100) + "...";
							else
								fixContent = contents.get(i);
					%>
					<td><%=fixContent%></td>
					<form method="post" action="Announce">
						<input type="hidden" name="delete" value="<%=contents.get(i)%>">
						<td><button class="btn btn-danger btn-xs" type="submit">Xóa</button></td>
					</form>
				</tr>
				<%
					}
				%>
				<!-- Show button dialog -->
				<tr>
					<center>
						<td colspan="3"><button class="btn btn-info btn-lg"
								data-toggle="modal" data-target="#myModal">Thêm thông
								báo</button></td>
					</center>
				</tr>
			</table>
		</div>
	</div>
	<!-- show addmodal -->
</div>
<form action="AnnounceAdding" method="get">
	<div class="modal fade" id="myModal" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h3 class="modal-title" id="myModalLabel">Thêm thông báo</h3>
				</div>
				<div class="modal-body">
					<textarea class="form-control" rows="25"
						placeholder="Nhập nội dung vào đây" name="content"></textarea>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
					<button type="submit" class="btn btn-primary">Save changes</button>
				</div>
			</div>
		</div>
	</div>
</form>
<jsp:include page="../includes/footer.jsp"></jsp:include>